#include <stdio.h>
#include <string.h>
#define SIZE_MAX 20
typedef struct String{
    char str[SIZE_MAX];
    int length;
}S, *List;
List addtion();
int index(List a, List b, int postion);
int main()
{
    int i;
    List a, b;
    a = addtion();
    b = addtion();
    printf("%d\n", index(a, b, 1));
    return 0;
}
List addtion(){
    List l;
    int i, n;
    l = (List)malloc(sizeof(S));
    scanf("%d", &n);
    l->length = n;
    getchar();
    for(i=1;i<=n;i++){
        scanf("%c", &l->str[i]);
    }
    return l;
}
int index(List a, List b, int postion){
    int i=postion,j=1;
    while(i<=a->length&&j<=b->length){
        if(a->str[i]==b->str[j]){
            ++i,++j;
        }else{
            i = i-j+2;
            j = 1;
        }
        if(j>b->length){
            return i-j+1;
        }
    }
    return 0;
}
